﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Framework.ExtensionsMods.Util
{
	public class CrontabScheduleUtil
	{
		/// <summary>
		/// 计算距离下一个发生时间相差时间戳
		/// </summary>
		/// <param name="baseTime">起始时间</param>
		/// <returns></returns>
		public static TimeSpan GetSleepTimeSpan(DateTime baseTime)
		{
			return TimeSpan.FromMilliseconds(GetSleepMilliseconds(baseTime));
		}

		/// <summary>
		/// 计算距离下一个发生时间相差毫秒数
		/// </summary>
		/// <param name="baseTime">起始时间</param>
		/// <returns></returns>
		public static double GetSleepMilliseconds(DateTime baseTime)
		{
			// 计算总休眠时间
			return (baseTime - DateTime.Now).TotalMilliseconds;
		}
	}
}
